<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>通知公告</title>
    <link href="../../../layuiadmin/js/adm/css/bootstrap.css"  rel="stylesheet">
    <script src="../../../layuiadmin/js/adm/js/vue.js"></script>
    <script src="../../../layuiadmin/js/adm/js/vue-resource.js"></script>
    <script src="../../../layuiadmin/js/adm/js/jquery.min.js"></script>
    <script src="../../../layuiadmin/js/adm/js/bootstrap.js"></script>
    <script src="../../../layuiadmin/js/adm/js/getUrlParam.js"></script>
    <script src="../../../layuiadmin/js/adm/js/date.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui@1.4/lib/theme-default/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui@1.4/lib/index.js"></script>
    <script src="../../../layuiadmin/js/adm/js/jquery.cookie.js"></script>
    <style>
       .c {
			text-align: right
		}
        body {
            margin-left: 50px
        }
    </style>
</head>
<body>
    <div id="app" class="container-fluid" style="margin-top: 20px">
        <!-- 模糊查询搜索引擎 -->
       <div class="row" style="margin-left: 20px">
           <form action="" method="POST" class="form-horizontal form-inline">
                <div class="col-xs-3">
                        <label>标题：</label>
                        <input type="text" placeholder="请输入标题" v-model="title" class="form-control" style="width: 75%" />      
                </div>
                <div class="col-xs-3" style="text-align: center">
                        <label>开始时间：</label>
                        <input type="date" class="form-control" v-model="kdate" style="width: 50%" />      
                </div>
                <div class="col-xs-3">
                        <label>结束时间：</label>
                        <input type="date" class="form-control" v-model="jdate" style="width: 50%" />      
                </div>
                <div class="col-xs-1">
                    <input type="button" value="开始检索" @click="postfuzzyquery()" class="btn btn-primary">
                </div>
           </form>
       </div>

       <!-- 表格主题 -->
       <div class="col-xs-12" style="margin-top: 20px;margin-left: 15px" >
            <table class="table table-condensed table-hover" >
                <thead>
                    <tr>
                        <th>标题</th>
                        <th>时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="item in notice">
                        <td>{{item.title}}</td>
                        <td>{{item.datetime|formatDate}}</td>
                        <td>
                            <div class="dropdown">
                                <button  @click.prevent="posthref(item.noticeId)" class="btn btn-default dropdown-toggle btn-sm" type="button"  aria-haspopup="true" aria-expanded="true">
                                  查看
                                </button>
                              </div>
                        </td>
                    </tr>
                </tbody>
            </table>
            
            
       </div>
    </div>
    

    <script>
          var vm=new Vue({
            el:'#app',
            data:{
                notice:[

                ],
                title:"",
                kdate:"",
                jdate:""
            },
            methods: {
                posthref(noticeid){
                        window.location.href="adm_query.html?id="+noticeid;
                },

                postinfo(){             //通知公告显示
                    this.$http.post("http://localhost:8080/adm/listallcelc",{},{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                        if(dat!=null&&dat!=""){
                            this.notice=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.notice.push(dat[i])
                            }
                        }else{
                            alert("获取失败")
                        }
                    })
                },
                postfuzzyquery(){   //模糊查询通知公告
                    var id="";
                    this.$http.post('http://localhost:8080/adm/fuzzyquery',{"title":this.title,"kdate":this.kdate,"jdate":this.jdate,"id":id},{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                        if(dat!=null&&dat!=""){
                            this.notice=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.notice.push(dat[i])
                            }
                        }else{
                            alert("获取失败")
                        }
                    })
                }
            },
            created () {
                this.postinfo()
            },
            filters: {
                formatDate: function (value) {      //将时间戳修改为时间单位格式
                    let date = new Date(value);
                    let y = date.getFullYear();
                    let MM = date.getMonth() + 1;
                    MM = MM < 10 ? ('0' + MM) : MM;
                    let d = date.getDate();
                    d = d < 10 ? ('0' + d) : d;
                    let h = date.getHours();
                    h = h < 10 ? ('0' + h) : h;
                    let m = date.getMinutes();
                    m = m < 10 ? ('0' + m) : m;
                    let s = date.getSeconds();
                    s = s < 10 ? ('0' + s) : s;
                    return y + '-' + MM + '-' + d ;
                    // return y + '-' + MM + '-' + d + 'T' + h + ':' + m ;
                }
            }
        })      
    </script>

</body>
</html>